class HomeController < ApplicationController
  
  def initialize
    @styleName="home"
  end

  def index
    @styleName="index"
    @pageTitle="首页"
  end

  def profile
    @member = current_accounts.member
    @pageTitle="我的主页"
  end

  def space
    @member = Member.find params[:id]
    @pageTitle="#{@member.nick}的主页"

    #save visitor
    unless(@member[:id] == session[:accounts_id].to_s)
      unless @member.guests.include?(current_accounts.member)
        @member.visitors.create :guest_id => current_accounts.member
      else
        visitor = @member.visitors.find_by_guest_id(current_accounts.member)
        visitor.update_attribute(:updated_at, DateTime.new)
      end
    end
  end

end